# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=golang-github-client9-misspell
pkgver=0.3.4
pkgrel=1
pkgdesc="Package for equality of Go values"
arch=('any')
url="https://github.com/client9/misspell"
license=('BSD')
depends=('go' 'golang-github-gobwas-glob')
source=("$pkgname-$pkgver.tar.gz::https://github.com/client9/misspell/archive/v$pkgver.tar.gz"
        $pkgname-remove-newline.patch::https://github.com/client9/misspell/pull/194.patch)
sha512sums=('6dfbc4aef932f18b8908efe75b6464cf444522ef0625f4abc1e9d40c5bb31238699634494cb24a0d3869336304df695ac6143784f53ca9e0d2d441b2e08eebcb'
            '3de10156cd9c8ffcaeee8786c80d495242685a9a36ac53c3c83bb7f16e6d8db5011c27d54e00c8677e40aef44a79348f7d2188c2eb2d3731e0113ccd41b78fb0')

prepare() {
  patch -d misspell-$pkgver -p1 < $pkgname-remove-newline.patch
}

check() {
  export GO111MODULE=off
  export GOPATH="$srcdir/build:/usr/share/gocode"
  mkdir -p "$srcdir"/build/src/github.com/client9
  cp -a "$srcdir"/misspell-$pkgver "$srcdir"/build/src/github.com/client9/misspell
  cd "$srcdir"/build/src/github.com/client9/misspell
  go test -v $(go list ./...)
}

package() {
  mkdir -p "$pkgdir"/usr/share/gocode/src/github.com/client9
  cp -a "$srcdir"/misspell-$pkgver "$pkgdir"/usr/share/gocode/src/github.com/client9/misspell

  install -Dm644 misspell-$pkgver/LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}
